<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate"> 
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> 
<META HTTP-EQUIV="expires" CONTENT="0"> 
<meta name="viewport" content="height=device-height,width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

<title>结伴旅行设备注册</title>
<link href="img/css/css.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="logo"><img src="img/logo.png"></div>
<div class="input_title mt20">请输入在MRN上显示的Device ID</div>
<div class="input_form mt20"><input name="deviceIds" id="deviceIds" value="1A32267BA122XXXX"  type="text" class="formstyle"/></div>
<div class="input_info mt20">
      <p>您要输入的Device ID可以在车机的"关于"中找到。</p>
      <p>您要输入的Device ID可以在车机的"关于"中找到。</p>
      <p>您要输入的Device ID可以在车机的"关于"中找到。</p>
</div>
<footer>
<div class="bottom_btn">
     <div class="left_btn"><p class="ico_group"><a href="javascript:void(0);" onclick="closePage()"><i class="iconfont img">&#xe601;</i>取消</a></p></div>
     <div class="right_btn line_left" id="b01"><p class="ico_group"><a href="#"><i class="iconfont img">&#xe602;</i>确定</a></p></div>
</div>
</footer>
</body>
</html>

<script type="text/javascript">
	function closePage(){
		if (navigator.userAgent.indexOf("MSIE") > 0) {
		  if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
		   window.opener = null;
		   window.close();
		  } else {
		   window.open('', '_top');
		   window.top.close();
		  }
		 }
		 else if (navigator.userAgent.indexOf("Firefox") > 0) {
		  window.location.href = 'about:blank ';
		 } else {
		  window.opener = null;
		  window.open('', '_self', '');
		  window.close();
		 }
	}
	$(document).ready(function(){
	  $("#b01").click(function(){
	  	var deviceId = document.getElementById("deviceIds").value;
			if(deviceId==null || deviceId=="" || deviceId.length!=16){
				alert("DEVICEID长度必须是16位");//1A32267BA0AB11221117
				return false;	
			}
			$.ajax({
	      type: "post",
	      url: "jsonPortal?deviceId="+deviceId+"&actionType=regDevice",
	      data: {},
	      dataType: "jsonp",
	      success: function (datas) {
	      		if(datas.portalResp.errcode==0){
	          	window.location.href = "scan.html?urls="+datas.portalResp.qrcode+"&qrcodeURL="+datas.portalResp.qrcodeURL;
	          }else if(datas.portalResp.errcode==1){
	          	alert("DEVICEID长度必须是20位");
	          }else if(datas.portalResp.errcode==100002){
	          	alert("该DEVICEID已经注册了");
	          }else if(datas.portalResp.errcode==2){
	          	alert("该DEVICEID未生效，请联系厂商。");
	          }
	      },
	      error: function (XMLHttpRequest, textStatus, errorThrown) {   
	      	alert(textStatus);      
	      }
	  	});
	  	
	  	
	  	
	  });
	  $('footer').show();
	
});

</script>